package com.yan.utils;

 

import jodd.http.HttpRequest;
import jodd.http.HttpResponse;

public class JoddUtil {

	public static void main(String args[]) {
	//	String url = "http://192.168.70.213:8080/chatServer/chat/sendPChatMessage/android/football?lang=zh&timeZone=8&message=&chatType=football&toUserId=null&sourceName=android&msgCode=1&msgId=e10ea908-dae9-4824-9ebf-5262f04d577b&thirdId=3482618&deviceId=357095063448756&userId=hhly90320&phoneNum=13570185327&userLogo=http://tp.13322.com/img/2017-06-06/9212f265-8f28-40e3-9032-a2cb412e633c.jpg&userNick=诸葛看盘";
		String url = "http://localhost:10088/JFinal/indexJson";
		HttpRequest httpRequest = HttpRequest.get(url).header("Accept-Encoding", "gzip");
		HttpResponse response = httpRequest.send().accept("utf-8")
				.header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip");

		System.out.println(response.body());
		System.out.println(GzipUtil.unGZip(response.bodyText()));

//		HttpClient client = (HttpClient) new HttpClientContext();
//		HttpPost post = new HttpPost(url);
//		
//		org.apache.http.HttpRequest request =new Htt
//		HttpResponse rep=	client.execute(post, paramHttpRequest)
//	 
//		Header[] headers = rep.getHeaders("Content-Encoding");
//		boolean isGzip = false;
//		for (Header h : headers) {
//			if (h.getValue().equals("gzip")) {
//				// 返回头中含有gzip
//				isGzip = true;
//			}
//		}
//		String responseString = null;
//		if (isGzip) {
//			// 需要进行gzip解压处理
//			responseString = EntityUtils.toString(new GzipDecompressingEntity(rep.getEntity()));
//		} else {
//			responseString = EntityUtils.toString(rep.getEntity());
//		}

		
		 
	}
}
